<form id="info-form" method="post">
    <table style="padding-left: 20px">
        <input type="hidden" name="id" value="@if(!empty($info)) {{$info['id']}} @endif" />
        @if(!empty($info)&&$info['parent_id']==0)

        @else
        <tr style="height: 50px;">
            <td align="right">上级菜单:</td>
            <td><input style="width:350px;height: 30px" id="form_parent_tree" name="parent_id" /></td>
        </tr>
        @endif
        <tr style="height: 50px;">
            <td width="60" align="right">菜单名称:</td>
            <td><input style="width:350px;height: 30px" class="easyui-textbox" name="name" data-options="required:true" value="@if(!empty($info)){{$info['name']}}@endif" /></td>
        </tr>
        <tr style="height: 50px;">
            <td width="60" align="right">菜单图标:</td>
            <td><input style="width:350px;height: 30px" id="icon_style" class="easyui-textbox" name="icon_style" data-options="icons:[{iconCls:'icon-search',
				handler: function(e){
					openIcon()
				}}],required:true" value="@if(!empty($info)){{$info['icon_style']}}@endif" /></td>
        </tr>
        <tr style="height: 50px;">
            <td width="60" align="right">同级排序:</td>
            <td><input style="width:350px;height: 30px" class="easyui-numberbox" name="sort" data-options="required:true,min:0" value="@if(!empty($info)){{$info['sort']}}@endif" /></td>
        </tr>
        <tr style="height: 50px;">
            <td width="60" align="right">菜单链接:</td>
            <td><input style="width:350px;height: 30px" class="easyui-textbox" name="menu_url" data-options="required:true" value="@if(!empty($info)){{$info['menu_url']}}@endif" /></td>
        </tr>
        <tr style="height: 50px;">
            <td width="60" align="right">菜单编码:</td>
            <td><input style="width:350px;height: 30px" class="easyui-textbox" name="code" value="@if(!empty($info)){{$info['code']}}@endif" /></td>
        </tr>
        <tr style="height: 50px;">
            <td width="80" align="right">菜单访问权限:</td>
            <td><input style="width:350px;height: 30px" class="easyui-textbox" name="permission" value="@if(!empty($info)){{$info['permission']}}@endif" /></td>
        </tr>
        <tr style="height: 50px;">
            <td align="right">是否有效:</td>
            <td><input type="text" name="is_active" @if(empty($info) || $info['is_active']) checked @endif class="easyui-switchbutton" data-options="onText:'是',offText:'否'" /></td>
        </tr>
    </table>
</form>
<div id="icon_dialog"></div>
<script>
    $(function () {
        parent_id = 0;
        @if(!empty($info))
        parent_id = '{{$info['parent_id']}}';
        parent_name = '{{$info['parent_name']}}';
        @elseif($parent_id)
        parent_id = '{{$parent_id}}';
        parent_name = '{{$parent_name}}';
        @endif

        $('#form_parent_tree').combotree({
            url: '/sys/menu/listTree',
            queryParams:{
                _token : $('meta[name="csrf-token"]').attr('content'),
                parent_id : parent_id
            },
            required: true
        });

        if(parent_id > 0){
            $("#form_parent_tree").combotree('setValue',{id:parent_id,text:parent_name});
        }

    });

    function  openIcon() {
        $('#icon_dialog').dialog({
            title: '选择图标',
            width: 400,
            height: 200,
            closed: false,
            cache: true,
            href: '/css/iconlist.html?v=' + Math.random() ,
            modal: true,
            buttons: [{
                text: '确定',
                iconCls: 'icon-ok',
                handler: function () {
                    $('#icon_style').textbox({value:$.trim($('.l-btn-icon-left').attr('data-selected-class'))});
                    $('#icon_dialog').dialog('close');
                }
            }, {
                text: '取消',
                iconCls: 'icon-cancel',
                handler: function () {
                    $('#icon_dialog').dialog('close');
                }
            }]
        });
    }
</script>

